#ifndef DATA_SQL_H_
#define DATA_SQL_H_

#define OrderTradeBaseFields "BrokerID char(31)," \
"InvestorID char(31)," \
"InstrumentID char(31)," \
"OrderRef char(9)," \
"UserID char(21),"

const char* sql_create_table_inputorders =
"create table if not exists InputOrder("
//"BrokerID char(31),"
//"InvestorID char(31),"
//"InstrumentID char(31),"
//"OrderRef char(9),"
//"UserID char(21),"
OrderTradeBaseFields
"OrderPriceType int,"
"Direction int,"
"CombOffsetFlag char(5),"
"CombHedgeFlag char(5),"
"LimitPrice double,"
"VolumeTotalOriginal int,"
"TimeCondition int,"
"GTDDate char(9),"
"VolumeCondition int,"
"MinVolume int,"
"ContingentCondition int,"
"StopPrice double,"
"RequestID int,"
"FrontID int,"
"SessionID int,"
"OrderSysID char(31),"
"ExchangeID char(9),"
"FrozenMargin double,"
"FrozenCommission double,"
"InsertDate char(31),"
"InsertTime char(9),"
"Primary Key(FrontID,OrderSysID))";



const char* sql_create_table_orders =
"create table if not exists InputOrder("
//"BrokerID char(31),"
//"InvestorID char(31),"
//"InstrumentID char(31),"
//"OrderRef char(9),"
//"UserID char(21),"
OrderTradeBaseFields
"OrderPriceType int,"
"Direction int,"
"CombOffsetFlag char(5),"
"CombHedgeFlag char(5),"
"LimitPrice double,"
"VolumeTotalOriginal int,"
"TimeCondition int,"
"GTDDate char(9),"
"VolumeCondition int,"
"MinVolume int,"
"ContingentCondition int,"
"StopPrice double,"
"RequestID int,"
"FrontID int,"
"SessionID int,"
"OrderSysID char(31),"
"ExchangeID char(9),"
"FrozenMargin double,"
"FrozenCommission double,"
"InsertDate char(31),"
"InsertTime char(9),"
"ForceCloseReason int,"
"IsAutoSuspend int,"
"BusinessUnit char(31),"
"OrderLocalID char(31),"
"ParticipantID char(31),"
"ClientID char(31),"
"ExchangeInstID char(31),"
"TraderID char(31),"
"InstallID int,"
"OrderSubmitStatus int,"
"NotifySequence int,"
"TradingDay char(31),"
"SettlementID int,"
"OrderSource int,"
"OrderStatus int,"
"OrderType int,"
"VolumeTraded int,"
"VolumeTotal int,"
"ActiveTime char(31),"
"SuspendTime char(31),"
"UpdateTime char(31),"
"CancelTime char(31),"
"ActiveTraderID char(31),"
"ClearingPartID char(31),"
"SequenceNo int,"
"UserProductInfo char(31),"
"StatusMsg char(31),"
"UserForceClose int,"
"ActiveUserID char(31),"
"BrokerOrderSeq int,"
"RelativeOrderSysID char(31),"
"ZCETotalTradedVolume int,"
"IsSwapOrder int,"
"SeatID int,"
"Primary Key(FrontID,OrderSysID))";


const char* sql_create_table_inputorderactions =
"create table if not exists InputOrderAction("
//"BrokerID char(31),"
//"InvestorID char(31),"
//"OrderActionRef char(31),"
//"OrderRef char(9),"
//"UserID char(21),"
OrderTradeBaseFields
"RequestID int,"
"Direction int,"
"CombOffsetFlag char(5),"
"CombHedgeFlag char(5),"
"LimitPrice double,"
"VolumeTotalOriginal int,"
"TimeCondition int,"
"GTDDate char(9),"
"VolumeCondition int,"
"MinVolume int,"
"ContingentCondition int,"
"StopPrice double,"
"RequestID int,"
"FrontID int,"
"SessionID int,"
"OrderSysID char(31),"
"ExchangeID char(9),"
"FrozenMargin double,"
"FrozenCommission double,"
"InsertDate char(31),"
"InsertTime char(9),"
"Primary Key(FrontID,OrderSysID))";



const char* sql_create_table_trades =
"create table if not exists Trade("
//"BrokerID char(31),"
//"InvestorID char(31),"
//"InstrumentID char(31),"
//"OrderRef char(9),"
//"UserID char(21),"
OrderTradeBaseFields
"ExchangeID char(9),"
"TradeID char(9),"
"Direction int,"
"OrderSysID char(31),"
"ParticipantID char(31),"
"ClientID char(31),"
"TradingRole int,"
"ExchangeInstID char(31),"
"OffsetFlag int,"
"HedgeFlag int,"
"Price double,"
"Volume int,"
"InsertDate char(31),"
"InsertTime char(9),"
"TradeType int,"
"PriceSource int,"
"TraderID char(9),"
"OrderLocalID char(9),"
"ClearingPartID char(9),"
"BusinessUnit char(31),"
"SequenceNo int,"
"TradingDay char(31),"
"SettlementID int,"
"BrokerOrderSeq int,"
"TradeSource int,"
"SeatID int,"
"Primary Key(FrontID,OrderSysID))";



const char* sql_create_table_InvestorPositionss =
"create table if not exists InvestorPosition("
"BrokerID char(31)," 
"InvestorID char(31)," 
"InstrumentID char(31)," 
"ExchangeID char(21),"
"ClientID char(21),"
"OpenDate char(9),"
"PosiDirection int,"
"HedgeFlag int,"
"PositionDate int,"
"YdPosition int,"
"Position int,"
"LongFrozen int,"
"ShortFrozen int,"
"LongFrozenAmount int,"
"ShortFrozenAmount int,"
"OpenVolume int,"
"CloseVolume int,"
"OpenAmount double,"
"CloseAmount double,"
"PositionCost double,"
"PreMargin double,"
"UseMargin double,"
"FrozenMargin double,"
"FrozenCash double,"
"FrozenCommission double,"
"CashIn double,"
"Commission double,"
"CloseProfit double,"
"PositionProfit double,"
"PreSettlementPrice double,"
"SettlementPrice double,"
"TradingDay char(9),"
"SettlementID int,"
"OpenCost double,"
"ExchangeMargin double,"
"CombPosition int,"
"CombLongFrozen int,"
"CombShortFrozen int,"
"CloseProfitByDate double,"
"CloseProfitByTrade double,"
"TodayPosition int,"
"MarginRateByMoney double,"
"MarginRateByVolume double,"
"StrikeFrozen int,"
"StrikeFrozenAmount double,"
"AbandonFrozen int,"
"OpenPrice double,"
"Primary Key(FrontID,OrderSysID))";


const char* sql_create_table_TradingAccounts =
"create table if not exists TradingAccount("
"BrokerID char(31),"
"AccountID char(31),"
"PreMortgage double,"
"PreCredit double,"
"PreDeposit double,"
"PreBalance double,"
"PreMargin double,"
"InterestBase double,"
"Interest double,"
"Deposit double,"
"Withdraw double,"
"FrozenMargin double,"
"FrozenCash double,"
"FrozenCommission double,"
"CurrMargin double,"
"CashIn double,"
"Commission double,"
"CloseProfit double,"
"PositionProfit double,"
"Balance double,"
"Available double,"
"WithdrawQuota double,"
"Reserve double,"
"TradingDay char(9),"
"UpdateTime char(9),"
"SettlementID int,"
"Credit double,"
"Mortgage double,"
"ExchangeMargin double,"
"DeliveryMargin double,"
"ExchangeDeliveryMargin double,"
"ReserveBalance double,"
"CurrencyID char(9),"
"PreFundMortgageIn double,"
"PreFundMortgageOut double,"
"FundMortgageIn double,"
"FundMortgageOut double,"
"FundMortgageAvailable double,"
"MortgageableFund double,"
"SpecProductMargin double,"
"SpecProductFrozenMargin double,"
"SpecProductCommission double,"
"SpecProductFrozenCommission double,"
"SpecProductPositionProfit double,"
"SpecProductCloseProfit double,"
"SpecProductPositionProfitByAlg double,"
"SpecProductExchangeMargin double,"
"Primary Key(FrontID,OrderSysID))";


const char* sql_create_table_SettlementInfos =
"create table if not exists SettlementInfo("
"TradingDay char(9),"
"BrokerID char(9),"
"InvestorID char(9),"
"Content text,"
"Primary Key(FrontID,OrderSysID))";

const char* sql_begin_transaction = "begin transaction;";

const char* sql_commit_transaction = "commit transaction;";
#endif